package com.panpay.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/Str")
public class StrServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        设定编码集
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html; charset=UTF-8");
//        存储数据a
        req.setAttribute("msgStr", "Hello  ");
        req.setAttribute("msgStr2", "aHello Freemarker");
//        转发
        req.getRequestDispatcher("template/f01.ftl").forward(req, resp);
    }
}
